/*
 ============================================================================
 Page	     : 334
 Name        : fgets3.c
 Date	     : 20210406
 Author      : Hbue 18060333
 Copyright   : Your copyright notice
 Description : 使用fgets()
 ============================================================================
 */

#include <stdio.h>
#define STLEN 10

int main(void)
{
	char words[STLEN];

	puts("Enter strings (empty line to quit):");
	while(fgets(words, STLEN, stdin) != NULL && words[0] != '\n')
	{
		int i = 0;
		while(words[i] != '\n' && words[i] != '\0')
		{
			i++;
		}
		if(words[i] == '\n')
		{
			words[i] = '\0';
		}
		else		// 如果word[i] = '\0' 则执行这段代码
		{
			while(getchar() != '\n')
			{
				continue;
			}
		}
		puts(words);
	}
	puts("Done");

	return 0;
}

